package com.myjob.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.myjob.entity.User;
import com.myjob.mapper.UserMapper;
import com.myjob.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Chen Yuan
 */

@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public User selectByPhoneOrEmil(String userName) {
        QueryWrapper<User> wrapper = new QueryWrapper<>();
        wrapper.and(w -> w.eq("phone", userName)
                .or().eq("email", userName));
        //连接数据库查询用户
        User user = userMapper.selectOne(wrapper);
        return user;
    }
}
